package apof.dao
{
	import flash.events.SQLEvent;
	import flash.data.SQLStatement;
	import flash.data.SQLResult;
	
	public class ResultHandler
	{
		public var callback:Function=null;
		public var stm:SQLStatement=null;
		public var ready:Boolean=false;
		public var result:Array=null;
		
		public function get func():Function {
			return handle;
		}
		
		public function ResultHandler(stm:SQLStatement, callback:Function=null) {
			this.stm=stm;
			this.callback=callback;
		}
		
		private function handle(event:SQLEvent):void {
			ready=true;
			if(stm.itemClass!=null && callback!=null) {
				var res:SQLResult=stm.getResult();
				result=res.data;
				callback(result);				
			}
		}
		
	}
}